<template>
	<view class="user_info">
		<view class="user">
			<!--用户头像 开始-->
			<view class="user_img">
				<image class="image" :src="uinfo.avatarUrl" mode="widthFix"></image>
			</view>
			<!--用户头像 结束-->
			<!--用户名称 开始-->
			<view class="user_name">
				<text class="nickName">{{uinfo.nickName}}</text>
			</view>
			<!--用户名称 结束-->
		</view>
		<!--地址 开始-->
		<!-- <text class="area">导航：{{uinfo.area}}</text> -->
		<!--地址 结束-->

		<!--按钮-->
		<view class="btn_list">
			<!-- openType="{{userInfo.mingpian_send>0?'share':''}}" -->
			<!-- <button
		 class="flex-1 ml-lg"
		 bindtap="goUrl"
		 type="default"
		>编辑资料
		</button> -->
			<button @tap="handleCall" :data-id="uinfo.phone" size="default">拨打电话
			</button>
			<button @tap="share" :data-id="uinfo.openId" formType="submit" openType="share" size="default" type="primary">一键分享名片
			</button>
		</view>
		<!--按钮-->

		<!--个人信息 开始-->
		<text class="index_text">个人信息</text>
		<view class="personnelUserInfo" v-if="!isPersonnelUserInfo">
			<view class="list-title">姓名：{{personnelUserInfo.uname}}</view>
			<!-- <view class="list-title">性别：{{personnelUserInfo.sex}}</view> -->
			<view class="list-title">民族：{{personnelUserInfo.nation}}</view>
			<view class="list-title">工种：{{personnelUserInfo.workType}}</view>
			<view class="list-title">手机：{{personnelUserInfo.phone}}</view>
			<view class="list-title">所在地区：{{uipersonnelUserInfonfo.area}}</view>
			<view class="list-title">自我介绍：{{personnelUserInfo.self}}</view>
		</view>
		<view class="personnelUserInfo" v-else>
			请填写你的个人信息
		</view>
		<!--个人信息 结束-->

		<!--人员信息 开始-->
		<text class="index_text">人员信息</text>
		<view class="personnel" v-if="personnel">
			<view class="list-title">工龄：{{personnel.workAge}}</view>
			<view class="list-title">家乡：{{personnel.home}}</view>
			<view class="list-title">熟练度：{{personnel.proficiency}}</view>
			<view class="list-title">人员构成：{{personnel.composition}}</view>
			<view class="list-title">人数：{{personnel.num}}</view>
		</view>
		<view class="personnel" v-else>
			请填写你的人员信息
		</view>
		<!--人员信息 结束-->

		<!--项目经验 开始-->
		<text class="index_text">项目经验</text>
		<view v-if="project.length>0">
			<view v-for="(item, index) in project" :key="index" class="project">
				<view class="list-title">项目名称：{{item.pojectTitle}}</view>
				<view class="list-title">开工时间：{{item.startTime}}</view>
				<view class="list-title">完工时间：{{item.endTime}}</view>
				<view class="list-title">所在地区：{{item.area}}</view>
				<view class="list-title">项目详情：{{item.projectDetail}}</view>
				<view class="constant-line"></view>
			</view>
		</view>
		<view class="project" v-else>
			请填写你的项目经验
		</view>

		<!--项目经验 结束-->

		<!--职业技能 开始-->
		<text class="index_text">职业技能</text>
		<view v-if="skills.length>0">
			<view v-for="(item, index) in skills" :key="index" class="skill">
				<view class="list-title">职业技能：{{item.skillName}}</view>
				<view class="list-title">领取证书时间：{{item.time}}</view>
			</view>
		</view>
		<view class="skill" v-else>
			请填写你的职业技能
		</view>
		<!--职业技能 结束-->
	</view>
</template>

<script>
	let app = getApp();

	export default {
		data() {
			return {
				uinfo: {},
				personnel: true,
				isPersonnel: true,
				project: [],
				skill: [],
				personnelUserInfo: "",
				isPersonnelUserInfo: false,
				skills: ""
			};
		},

		components: {},
		props: {},
		//options(Object)
		onLoad: function(options) {
			uni.request({
				url: `${app.globalData.baseUrl}/user/getAllUserInfo/${uni.getStorageSync("openid")}`,
				// 目标服务器url
				method: 'GET',
				dataType: 'json',
				header: {
					'content-type': 'application/json'
				},
				success: res => {
					console.log('查询成功', res.data);
					this.setData({
						uinfo: res.data.dataMap.data
					});
				}
			});
			uni.request({
				url: `${app.globalData.baseUrl}/user/getUserInfo/${uni.getStorageSync("openid")}`,
				// 目标服务器url
				method: 'GET',
				dataType: 'json',
				header: {
					'content-type': 'application/json'
				},
				success: res => {
					console.log('个人信息', res.data);
					this.setData({
						personnelUserInfo: res.data.dataMap.data,
						isPersonnelUserInfo: false
					});
				}
			});
			uni.request({
				url: `${app.globalData.baseUrl}/mallappletbackstage/personnel-info/getInfo/${uni.getStorageSync("openid")}`,
				// 目标服务器url
				method: 'GET',
				dataType: 'json',
				header: {
					'content-type': 'application/json'
				},
				success: res => {
					console.log('人员信息', res.data);
					this.setData({
						personnel: res.data.dataMap.data,
						isPersonnel: false
					});
				}
			});
			uni.request({
				url: `${app.globalData.baseUrl}/mallappletbackstage/project-experience/getProject/${uni.getStorageSync("openid")}`,
				// 目标服务器url
				method: 'GET',
				dataType: 'json',
				header: {
					'content-type': 'application/json'
				},
				success: res => {
					console.log('项目经验', res.data);
					this.setData({
						project: res.data.dataMap.data
					});
				}
			});
			uni.request({
				url: `${app.globalData.baseUrl}/mallappletbackstage/skills-certificate/getSkills/${uni.getStorageSync("openid")}`,
				// 目标服务器url
				method: 'GET',
				dataType: 'json',
				header: {
					'content-type': 'application/json'
				},
				success: res => {
					console.log('职业技能', res.data);
					this.setData({
						skills: res.data.dataMap.data
					});
				}
			});
		},
		onShow: function() {
			uni.request({
				url: `${app.globalData.baseUrl}/user/getAllUserInfo/${uni.getStorageSync("openid")}`,
				// 目标服务器url
				method: 'GET',
				dataType: 'json',
				header: {
					'content-type': 'application/json'
				},
				success: res => {
					console.log('查询成功', res.data);
					this.setData({
						uinfo: res.data.dataMap.data
					});
				}
			});
			uni.request({
				url: `${app.globalData.baseUrl}/user/getUserInfo/${uni.getStorageSync("openid")}`,
				// 目标服务器url
				method: 'GET',
				dataType: 'json',
				header: {
					'content-type': 'application/json'
				},
				success: res => {
					console.log('个人信息', res.data);
					this.setData({
						personnelUserInfo: res.data.dataMap.data
					});
				}
			});
			uni.request({
				url: `${app.globalData.baseUrl}/mallappletbackstage/personnel-info/getInfo/${uni.getStorageSync("openid")}`,
				// 目标服务器url
				method: 'GET',
				dataType: 'json',
				header: {
					'content-type': 'application/json'
				},
				success: res => {
					console.log('人员信息', res.data);
					this.setData({
						personnel: res.data.dataMap.data
					});
				}
			});
			uni.request({
				url: `${app.globalData.baseUrl}/mallappletbackstage/project-experience/getProject/${uni.getStorageSync("openid")}`,
				// 目标服务器url
				method: 'GET',
				dataType: 'json',
				header: {
					'content-type': 'application/json'
				},
				success: res => {
					console.log('项目经验', res.data);
					this.setData({
						project: res.data.dataMap.data
					});
				}
			});
			uni.request({
				url: `${app.globalData.baseUrl}/mallappletbackstage/skills-certificate/getSkills/${uni.getStorageSync("openid")}`,
				// 目标服务器url
				method: 'GET',
				dataType: 'json',
				header: {
					'content-type': 'application/json'
				},
				success: res => {
					console.log('职业技能', res.data);
					this.setData({
						skills: res.data.dataMap.data
					});
				}
			});
		},
		onShareAppMessage: function(res) {
			console.log('res', res);

			if (res.from === 'button') { // 来自页面内转发按钮
			}

			return {
				title: '我的名片',
				//path: `/pages/card/index/index?openId=${this.uinfo.openId}`,
				path: `/pages/card/index/share/share?openId=${res.target.dataset.id}`,
				//path: `/pages/card/square/square?openId=${res.target.dataset.id}`
				desc: '分享'
			};
		},
		methods: {
			handleCall: function(e) {
				console.log(e);
				uni.makePhoneCall({
					phoneNumber: e.currentTarget.dataset.id
				});
			},

			onShareTimeline() {}

		}
	};
</script>
<style>
	.user_info {}

	.user {
		display: flex;
		flex-direction: column;
		align-items: center;
		width: 750rpx;
	}

	.user_img {
		width: 50%;
		height: 50%;
	}

	.user_name {}

	.info {
		background: #ffffff;
	}

	.uinfo {
		background: #ffffff;
	}

	.personnelUserInfo {
		background: #ffffff;
	}

	.personnel {
		background: #ffffff;
	}

	.project {
		background: #ffffff;
	}

	.skill {
		background: #ffffff;
	}

	.index_text {
		text-align: center;
		font-weight: 650;
		font-size: 34rpx;
		line-height: 25rpx;
	}

	.btn_list {
		background: #fff;
		display: flex;
		align-items: center;
		padding: 60rpx 32rpx 0;
	}

	.out {
		background: white;
		padding: 20px 10px;
		width: 100%;
		white-space: nowrap;
		box-sizing: border-box;
	}

	/*设置行内块*/

	.out .item {
		width: 100px;
		height: 30px;
		border-radius: 30px;
		border: 1px solid #8AC007;
		display: inline-block;
		margin-right: 10px;
		text-align: center;
	}

	.constant-line {
		width: 718px;
		height: 1px;
		background: #EEEEEE;
	}
</style>
